#ifndef PARSEGPX_H_
#define PARSEGPX_H_

#include "WaypointDB.h"

#include <stdexcept>
#include <sstream>

#include <iostream>
using std::cout;
using std::endl;

#include <string>
using std::string;

#include <xercesc/parsers/XercesDOMParser.hpp>
#include <xercesc/dom/DOM.hpp>
#include <xercesc/sax/HandlerBase.hpp>
#include <xercesc/util/XMLString.hpp>
#include <xercesc/util/PlatformUtils.hpp>
using namespace xercesc;

class ParseGPX
{
public:
	ParseGPX(string gpxFilename, WaypointDB& theDB);
	virtual ~ParseGPX();

private:

	// Loads the XML from the file into the DOM
	bool loadGPXFile(void);
	void loadWaypointsIntoDB();
	void addDataToDB(const string& name, const string& description, const string& latitude, const string& longitude);

private:

	// The filename (with path) to the GPX file
	string gpxFilename;

	// The Xerces parser
	XercesDOMParser* parser;

	// Xerces error handler
	ErrorHandler* errHandler;

	// The database we will save the GPX data to
	WaypointDB& dbToSaveTo;
};

#endif /* PARSEGPX_H_ */
